import 'dart:convert';

CouponModel couponModelFromJson(String str) => CouponModel.fromJson(json.decode(str));

String couponModelToJson(CouponModel data) => json.encode(data.toJson());

class CouponModel {
  int code;
  String? msg;
  List<CouponData> data;

  CouponModel({
    required this.code,
    required this.msg,
    required this.data,
  });

  factory CouponModel.fromJson(Map<String, dynamic> json) => CouponModel(
        code: json["code"],
        msg: json["msg"],
        data: List<CouponData>.from(json["data"].map((x) => CouponData.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "code": code,
        "msg": msg,
        "data": List<dynamic>.from(data.map((x) => x.toJson())),
      };
}

class CouponData {
  int id;
  int uid;
  int status;
  String name;
  double discount;
  double threshold;
  int termTime;
  String endTime;
  String createTime;

  CouponData({
    required this.id,
    required this.uid,
    required this.name,
    required this.status,
    required this.discount,
    required this.threshold,
    required this.termTime,
    required this.endTime,
    required this.createTime,
  });

  factory CouponData.fromJson(Map<String, dynamic> json) => CouponData(
        id: json["id"],
        uid: json["uid"],
        name: json["name"],
        status: json["status"],
        discount: json["discount"],
        threshold: json["threshold"],
        termTime: json["termTime"],
        endTime: json["endTime"],
        createTime: json["createTime"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "uid": uid,
        "name": name,
        "status": status,
        "discount": discount,
        "threshold": threshold,
        "termTime": termTime,
        "endTime": endTime,
        "createTime": createTime,
      };
}
